<template>
	<view class="content">
		<swiper :indicator-dots="true" :autoplay="true" :interval="3000" :duration="1000">
			<swiper-item v-for="item,index in list">
				<view class="swiper-item"><image :src="'../../static'+item.icon" mode="" style="width: 100%; height: 240px;"></image></view>
			</swiper-item>
		</swiper>
		
		<uni-section title="功能列表" >
			
			<uni-grid :column="5">
				<uni-grid-item v-for="(item,index) in typelist" v-if="index<=6"
				:index="item.id">
					<view class="grid-item" @click="gongge(item.id)">
						<image :src="'../../static'+item.icon" 
						style="width: 45px;height: 45px;"
						mode=""></image>
						<text>{{item.functionname}}</text>
					</view>
				</uni-grid-item>
			</uni-grid>
			
		</uni-section>
		
	</view>
</template>

<script>
	import axios from 'axios'; //导入 axios 请求（是个插件）
	export default {
		data() {
			return {
			"list": [],
			"typelist": []
			}
		},
		onLoad() {//进入页面执行的生命周期函数
		this.F_addone()//请求 F_addone 函数
		this.F_schoolSwiper()//请求 F_schoolSwiper 函数
		},
		methods: {
			
			
			F_addone(){
				console.log(11)
				//请求功能列表
				axios.post('http://localhost:8090/freshmenapp/function/list')
				//res：请求的结果（是个变量）
				        .then(res => {
				          console.log(res.data)
				          // 处理返回的数据
						  this.typelist = res.data.list
				        })
				        .catch(error => {
				          console.error(error);
				          // 处理错误情况
				        });
			},
			F_schoolSwiper(){
				//请求 banner
				axios.post("http://localhost:8090/freshmenapp/schoolSwiper/list").then(response=>{
					this.list = response.data.list
				})
			},
			gongge(id){
				console.log(id)
				
				if(id==3){
					//根据id跳转到对应的页面 
					uni.navigateTo({//跳转的api
						url: ''
					});
				}
			}
		}
	}
</script>

<style>
	.container {
		padding: 0;
		font-size: 14px;
		line-height: 24px;
	}
	.grid-item{
		display: flex;
		align-items: center;
		justify-content: center;
		flex-direction: column;
	}
</style>
